#include "junix.h"
using namespace std;

struct A
{
	string hello;
	A(const std::string& s):hello(s){ }
	friend ostream& operator<< (ostream& os,const A& a)
	{
		os<<a.hello;
		return os;
	}
};

int main(int argc, char **argv)
{
	typedef std::vector<boost::any> VANY;
	VANY va;

	std::string s="hello,world.";
	int i=8888;
	double d=3.1415926;
	A a("Junix");

	boost::any ay;
	ay=s;
	va.push_back(ay);
	ay=i;
	va.push_back(ay);
	ay=d;
	va.push_back(ay);
	ay=a;
	va.push_back(ay);

	cout<<va.size()<<endl;

	BOOST_FOREACH(boost::any& nay, va)
	{
		try{
			std::string ns=boost::any_cast<std::string>(nay);
			cout<<ns<<endl;
		}catch(boost::bad_any_cast& e){
//			cout<<e.what()<<endl;
		}

		try{
			int ni=boost::any_cast<int>(nay);
			cout<<ni;
		}catch( boost::bad_any_cast& e)	{
//			cout<<e.what()<<endl;
		}

		try{
			double nd=boost::any_cast<double>(nay);
			cout<<nd<<endl;
		}catch(boost::bad_any_cast& e){
//			cout<<e.what()<<endl;
		}

		try{
			A na= boost::any_cast<A>(nay);
			cout<<na<<endl;
		}catch( boost::bad_any_cast& e){
//			cout<<e.what()<<endl;
		}
	}
}
